setwd("/home1/30/jc227089/LD_inv/PBS_files")

dc<-rep(0.1, 10)

script.file<-'/home1/30/jc227089/evo-dispersal/LD/LD_sims.r'

for (ii in 1:length(dc)) {
	##create the sh file
	zz = file(paste('LD_',ii,'.sh',sep=''),'w')
		cat('##################################\n',file=zz)
		cat('#!/bin/sh\n',file=zz)
		cat('cd $PBS_O_WORKDIR\n',file=zz)
		cat("R CMD BATCH --no-save --no-restore '--args lb=5 rr=3 fid=",ii, " dc=",dc[ii], "' ",script.file,' LD_',ii,'.Rout \n',sep='',file=zz)
		cat('##################################\n',file=zz)
	close(zz)
			
	#submit the job
	system(paste('qsub -m n LD_',ii,'.sh',sep=''))
}
